

#ifndef RAITO_UDP_H
#define RAITO_UDP_H

#include <stdio.h>
#include <stdlib.h>

#include "stdbool.h"
#include "linklist.h"
#include "linkmap.h"
#include "number.h"


#ifdef __cplusplus
extern "C"
{
#endif


typedef enum SeqFlag{
	COMPLETED,
	WAITING,
	ERROR,
	BL_FORWARD,
	UDP_FORWARD,
	IGNORE,
	SEND_ACK_DATA,
	RECV_ACK_DATA,
	DISABLE_FORWARD,
}SeqFlag;

typedef struct DataKey{
	uint64_t seq;
	uint16_t src;
}DataKey;

typedef struct ForwardData{

	uint64_t seq;
	uint16_t src;
	uint8_t ttl;

}ForwardData;


int printit();


void dataBufferCreate(int size);


void setDataMTU(int mtu);


void myAddress(uint16_t address);


void nextSeqHandler(uint64_t (*next_seq)());


void enableForward(uint8_t seqFlag);


void dataHandler(void (*data_cb)(uint16_t dst, Bytes *bytes, SeqFlag flag));


Bytes *toSendAck(uint16_t src, uint16_t dst,uint64_t recvSeq, uint8_t seg0);

void encode(uint8_t *data, int len);


LinkList *decode(uint8_t *data, int len, uint16_t src, uint16_t dst);



#ifdef __cplusplus
}
#endif

#endif
